package com.eveinfo.sql.data;

import java.util.ArrayList;
import java.util.HashMap;

import com.eveinfo.api.asset.ApiAsset;
import com.eveinfo.display.asset.AssetComparable;

public class Item implements AssetComparable {

	private final int typeID;
	private final int groupID;
	private final int categoryID;
	private final String typeName;
	private final String description;
	private final int graphicID;
	private final double radius;
	private final double mass;
	private final double volume;
	private final double capacity;
	private final int portionSize;
	private final int raceID;
	private final double basePrice;
	private final boolean published;
	private final int marketGroupID;
	private final double chanceOfDuplicating;
	private final HashMap<Integer, ArrayList<ApiAsset>> assets;
	private long quantity;

	private final String icon;

	public Item(int typeID, int groupID, int categoryID, String typeName, String description, int graphicID, double radius,
			double mass, double volume, double capacity, int portionSize, int raceID, double basePrice,
			boolean published, int marketGroupID, double chanceOfDuplicating, String icon) {
		this.typeID = typeID;
		this.groupID = groupID;
		this.categoryID = categoryID;
		this.typeName = typeName;
		this.description = description;
		this.graphicID = graphicID;
		this.radius = radius;
		this.mass = mass;
		this.volume = volume;
		this.capacity = capacity;
		this.portionSize = portionSize;
		this.raceID = raceID;
		this.basePrice = basePrice;
		this.published = published;
		this.marketGroupID = marketGroupID;
		this.chanceOfDuplicating = chanceOfDuplicating;
		this.icon = icon;
		this.assets = new HashMap<Integer, ArrayList<ApiAsset>>();
		this.quantity = 0;
	}

	public int getTypeID() {
		return typeID;
	}

	public int getGroupID() {
		return groupID;
	}

	public String getTypeName() {
		return typeName;
	}

	public String getDescription() {
		return description;
	}

	public int getGraphicID() {
		return graphicID;
	}

	public double getRadius() {
		return radius;
	}

	public double getMass() {
		return mass;
	}

	public double getVolume() {
		return volume;
	}

	public double getCapacity() {
		return capacity;
	}

	public int getPortionSize() {
		return portionSize;
	}

	public int getRaceID() {
		return raceID;
	}

	public double getBasePrice() {
		return basePrice;
	}

	public boolean isPublished() {
		return published;
	}

	public int getMarketGroupID() {
		return marketGroupID;
	}

	public double getChanceOfDuplicating() {
		return chanceOfDuplicating;
	}

	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder();
		sb.append("" + typeID + "" + groupID + "" + typeName + "" + description + "" + graphicID + "" + radius + ""
				+ mass + "" + volume + "" + capacity + "" + portionSize + "" + raceID + "" + basePrice + "" + published
				+ "" + marketGroupID + "" + chanceOfDuplicating);
		return sb.toString();
	}

	public String getIcon() {
		return icon;
	}

	public void addAsset(ApiAsset asset) {
		quantity += asset.getQuantity();
		ArrayList<ApiAsset> arrayList = assets.get(asset.getLocationID());
		if(arrayList == null){
			arrayList = new ArrayList<ApiAsset>();
		}
		arrayList.add(asset);
		assets.put(asset.getLocationID(), arrayList);
	}
	
	public HashMap<Integer, ArrayList<ApiAsset>> getAssets() {
		return assets;
	}

	public int getCategoryID() {
		return categoryID;
	}

	public long getQuantity() {
		return quantity;
	}
}
